package com.example.springblog.service;

import com.example.springblog.mapper.BlogInfoMapper;
import com.example.springblog.model.BlogInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BlogService {
    @Autowired
    private BlogInfoMapper blogInfoMapper;

    public List<BlogInfo> getList(){
        return blogInfoMapper.selectAll();
    }

    public BlogInfo getBlogDetail(Integer id){
        return blogInfoMapper.selectById(id);
    }

    public boolean insert(BlogInfo blogInfo) {

        Integer result = blogInfoMapper.insertBlog(blogInfo);
        if(result == 1){
            return true;
        }
        return false;
    }
    public Integer delete(BlogInfo blogInfo){

        return blogInfoMapper.updataAll(blogInfo);
    }
    public Integer updata(BlogInfo blogInfo){
        return blogInfoMapper.updataAll(blogInfo);
    }
}
